package com.bdqn.t350.servlet;

import com.alibaba.fastjson.JSON;
import com.bdqn.t350.entity.Pet;
import com.bdqn.t350.entity.Powerbattery;
import com.bdqn.t350.service.PetService;
import com.bdqn.t350.service.PetServiceImp;
import com.bdqn.t350.service.PowerbatteryService;
import com.bdqn.t350.service.PowerbatteryServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

@WebServlet(name = "ListServlet", urlPatterns = "/ListServlet")
public class ListServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("doget");
        resp.setContentType("text/html;charset=UTF-8");
//        PetService petService = new PetServiceImp();
//        String petName = req.getParameter("petName");
//        Pet petEntity = new Pet();
//        petEntity.setPetName(petName);
//        List<Pet> list = petService.getListBiz(petEntity);
//        String str = JSON.toJSONString(list);
//        PrintWriter out = resp.getWriter();
//        out.print(str);
//        out.flush();
//        out.close();

        PowerbatteryService powerbatteryService = new PowerbatteryServiceImp();
        List<Powerbattery> list = powerbatteryService.list();
        String str = JSON.toJSONString(list);
        PrintWriter out = resp.getWriter();
        out.print(str);
        out.flush();
        out.close();

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    /*    System.out.println("dopost");
        resp.setContentType("text/html;charset=UTF-8");
        PetService petService = new PetServiceImp();
        List<Pet> list = petService.getListBiz();
        String str = JSON.toJSONString(list);
        PrintWriter out = resp.getWriter();
        out.print(str);
        out.flush();
        out.close();*/
    }
}
